//
//  InfoViewController.m
//  DeliciousFood1
//
//  Created by brother on 15/10/21.
//  Copyright © 2015年 com.hxm. All rights reserved.
//

#import "InfoViewController.h"
#define HeadUrl @"http://localhost:8888/head/"
#import "User.h"
#import "UIImage+CLImageCircle.h"
#import "AppDelegate.h"
#import "MyLoginViewController.h"

@interface InfoViewController ()
@property (weak, nonatomic) IBOutlet UIButton *head;
@property (weak, nonatomic) IBOutlet UILabel *name;

@end

@implementation InfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    AppDelegate *application =  [[UIApplication sharedApplication] delegate] ;
    if (application.user == nil) {
        NSLog(@"%@",application.user);
    }else
    {
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HeadUrl,application.user.head]]];
        NSLog(@"%@",[NSString stringWithFormat:@"%@%@",HeadUrl,application.user.head]);
        [self.head setBackgroundImage:[UIImage circleImageWithOldImage:[UIImage imageWithData:data] WithBorder:0 WithColor:nil] forState:UIControlStateNormal];
        self.name.text = application.user.username;
        NSLog(@"%@",application.user.username);
    }
}
- (IBAction)login:(id)sender {
    [self performSegueWithIdentifier:@"login" sender:nil];
}


- (void)loginRefresh
{
    [self viewDidLoad];
}

@end
